<?php
include ('cruceros.php');


class filtros_links_cruceros extends filtros_cruceros{
	
	public $filters_type				= 'links';
	public $filtros_adicionales 		= array('compania','barco','puerto','noches','periodo');
	public $filtros_obligatorios		= array( 'ocupantes'=>'','region'=>'' );
	public $url_den						= 'cruceros/resultados';
	
	function get_display_text($denomination,$value){
		global $db,$arrayMeses;
		$return_string = '';
		switch ($denomination){
			case 'compania' : 
				$query 				= 'SELECT nombre FROM cru_companias WHERE codigo = "' . $value . '"';
				$nombre_compania	= $db->getOne($query);
				$return_string 		= 'Cruceros de ' . $nombre_compania;
			break;
			case 'barco' : 
				$query 			= 'SELECT nombre FROM cru_barcos WHERE id_barco = ' . $value;
				$nombre_barco	= $db->getOne($query);
				$return_string 	= 'Cruceros del ' . $nombre_barco;
			break;
			case 'puerto' : 
				$query 			= 'SELECT nombre FROM cru_ciudades WHERE codigo = "' . $value . '"';
				$nombre_puerto	= $db->getOne($query);
				$return_string 	= 'Salida desde ' . $nombre_puerto;
			break;
			case 'noches' : 
				$return_string 	= $value . ' noches';
			break;
			case 'periodo' : 
				$temp			= explode('_',$value);
				$return_string 	= 'periodo ' . $arrayMeses[$temp[0]-1] . ' ' . $temp[1];
			break;
			case 'region' : 
				$query 			= 'SELECT region FROM cru_regiones WHERE id_region = ' . $value;
				$region			= $db->getOne($query);
				$return_string 	= 'Cruceros por ' . $region;
			break;
		}
		return $return_string;
	}
	
	function __construct($url,$region_id,$currency='$'){
	
		$this->init_aditional_filters($url);
		$this->region_id = $this->filtros_obligatorios['region'];
		
		parent::__construct($currency);
		
	}
	
	function get_parameters($string){
		$return = array();
		return $return;
	}
	
	function get_filter_url($base_url,$invoker_filter,$invoker_value,$filtros_adicionales){
		$url = $base_url;
		$description_string = 'cruceros';
		
		$return = '/' . $url;
		
		if (!is_null($invoker_filter) && !is_null($invoker_value)){
			$return .= '/' . $invoker_filter . '/' . $invoker_value;
		}
		
		if ($filtros_adicionales != ""){
			$return .= '/' . $filtros_adicionales;
		}
		return $return . '/' . $description_string;
	}

	function get_display_value($denomination,$value,$display_value,$text){
		global $arrayMeses;
		switch ($denomination){
			case 'periodo' :
				$temp			= explode('_',$value);
				$return_string	= $arrayMeses[$temp[0]-1] . ' ' . $temp[1];
			break;
			case 'puerto' :
				$return_string = str_replace('<value>',ucfirst(strtolower($display_value)),$text);
			break;
			case 'region' :
				$temp = explode('_',$display_value);
				$display_value = $temp[0];
				if ( isset($temp['1']) && $temp['0'] != $temp['1']){
					$display_value .= ' (' . $temp['1'] . ')';
				}
				$return_string = $display_value;				
			break;
			default:
				$return_string = str_replace('<value>',$display_value,$text);
			break;
		}
		return $return_string;
	}		
}


?>